import { createApp } from 'vue'
import { createPinia } from 'pinia'
import lazyPlugin from 'vue3-lazy'
import App from './App.vue'
import router from './router'
import './assets/main.css'
const app = createApp(App)

app.use(lazyPlugin, {
  // loading: require('@/assets/images/default.png'), // 图片加载时默认图片
  // error: require('@/assets/images/error.png')// 图片加载失败时默认图片
})

router.beforeEach((to, from, next) => {

  if (to.name == 'video' || to.name == 'my'||to.name=='shoppingcart') {
    if (sessionStorage.token) {
      next()
    } else {
      next('/singin')
    }

  }else {
    next()
  }
})

app.use(createPinia())
app.use(router)

app.mount('#app')
